import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

# 创建谷歌浏览器对象
EdgeDriver = webdriver.Edge()

# 窗口最大化
EdgeDriver.maximize_window()

# 打开百度网址
# EdgeDriver.get("http://www.baidu.com")
EdgeDriver.get("https://demo6.tp-shop.cn/")

time.sleep(1)
#点击新闻按钮
# EdgeDriver.find_element(By.XPATH, '//*[@id="s-top-left"]/a[1]').click()
# EdgeDriver.find_element(By.ID, "chat-textarea").send_keys("deepseek")
# EdgeDriver.find_element(By.CLASS_NAME, "chat-input-textarea.chat-input-scroll-style").send_keys("deepseek")
# EdgeDriver.find_element(By.TAG_NAME, "textarea").send_keys("deepseek")
# EdgeDriver.find_element(By.XPATH, '//*[@id="chat-textarea"]').send_keys("deepseek")
# EdgeDriver.find_element(By.XPATH, '/html/body/div[1]/div[2]/div[3]/div/div/div[2]/div/div/div[1]/div/div[1]/div[4]/div[1]/div[2]/textarea').send_keys("deepseek")
# EdgeDriver.find_element(By.XPATH, '//textarea[@id="chat-textarea"]').send_keys("deepseek")
# EdgeDriver.find_element(By.XPATH, '//*[@id="chat-textarea" and @class="chat-input-textarea chat-input-scroll-style"]').send_keys("deepseek")
# EdgeDriver.find_element(By.XPATH, '//*[@id="chat-textarea" or @class="chat-input-textarea chat-input-scroll-style"]').send_keys("deepseek")
# EdgeDriver.find_element(By.XPATH, '//textarea[contains(@id,"chat-")]').send_keys("deepseek")
# EdgeDriver.find_element(By.XPATH, '//textarea[starts-with(@id,"chat-")]').send_keys("deepseek")
# EdgeDriver.find_element(By.CSS_SELECTOR, 'textarea#chat-textarea.chat-input-textarea.chat-input-scroll-style').send_keys("Python自动化测试")
# EdgeDriver.find_element(By.LINK_TEXT, '图片').click()
# EdgeDriver.find_element(By.PARTIAL_LINK_TEXT, '片').click()
# EdgeDriver.find_element(By.XPATH, '//a[6]').click()

# EdgeDriver.find_element(By.XPATH, '//*[@id="chat-textarea"]').send_keys("Python自动化测试",Keys.ENTER)
# time.sleep(3)
# EdgeDriver.find_element(By.CSS_SELECTOR, 'span.tts-b-hl').click()

WebDriverWait(EdgeDriver,4).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[2]/div[1]/div/div[1]/div[1]/a[1]'))).click()
EdgeDriver.find_element(By.XPATH, '//*[@id="username"]').send_keys("15800000001")
time.sleep(1)
EdgeDriver.find_element(By.XPATH, '//*[@id="password"]').send_keys("123456")
time.sleep(1)
EdgeDriver.find_element(By.XPATH, '//*[@id="verify_code"]').send_keys("sr8s")
time.sleep(1)
EdgeDriver.find_element(By.XPATH, '//*[@id="login-form"]/div[5]/a').click()


time.sleep(2)
# 退出浏览器
EdgeDriver.quit()
